import { getMedicalOrderDetail } from "@/apis/order"
import type { MedicalOrderDetail } from "@/types/order"
import { onMounted, ref } from "vue"

// hooks函数 --> 对组件中的一些业务功能进行封装
export const useMedic = (orderId: string)=>{
  // 1. 药品订单详情
  const orderDetail = ref({} as MedicalOrderDetail)
  // 查询订单详情
  const getOrderDetail = async () => {
    // 订单详情接口
    const data = await getMedicalOrderDetail(orderId)
    // 渲染订单数据
    orderDetail.value = data
    console.log(orderDetail.value);
  }
  // 查询药品订单详情
  onMounted(() => {
    getOrderDetail()
  })

  return {
    orderDetail
  }
}